// ErrorHandling.h: interface for the CErrorHandling class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ERRORHANDLING_H__AA7C1728_153A_467F_A0BD_89C51B9220AF__INCLUDED_)
#define AFX_ERRORHANDLING_H__AA7C1728_153A_467F_A0BD_89C51B9220AF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CErrorHandling  
{
public:
	static CErrorHandling * GetErrorHandling()
	{
		if (NULL == _singleton)
			_singleton = new CErrorHandling;
		return _singleton;
	}
	static void SetErrorMessage(bstr_t message)
	{
		CErrorHandling * pErr = CErrorHandling::GetErrorHandling();
		pErr->SetErrorMessageEx(message);
	}
	void SetErrorMessageEx(bstr_t message)
	{
		ICreateErrorInfo *pcerrinfo;
		IErrorInfo *perrinfo;
		HRESULT hr;

		hr = CreateErrorInfo(&pcerrinfo);

		pcerrinfo->SetDescription(message);

		hr = pcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID FAR*) &perrinfo);
		if (SUCCEEDED(hr))
		{
			SetErrorInfo(0, perrinfo);
			perrinfo->Release();
		}
		pcerrinfo->Release();
	}
protected:
	CErrorHandling();
	virtual ~CErrorHandling();	
private:
	static CErrorHandling * _singleton;

};

#endif // !defined(AFX_ERRORHANDLING_H__AA7C1728_153A_467F_A0BD_89C51B9220AF__INCLUDED_)
